package net.lab1024.sa.ai.stream.module.business.ai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import net.lab1024.sa.ai.stream.module.business.ai.entity.AiModelConfigEntity;
import net.lab1024.sa.ai.stream.module.business.ai.mapper.AiModelConfigMapper;
import net.lab1024.sa.ai.stream.module.business.ai.model.dto.AiModelConfigDTO;
import net.lab1024.sa.ai.stream.module.business.ai.service.AiModelConfigService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

@Service
public class AiModelConfigServiceImpl implements AiModelConfigService {

    @Autowired
    private AiModelConfigMapper aiModelConfigMapper;

    @Override
    public AiModelConfigEntity getByModelName(String modelName) {
        return aiModelConfigMapper.selectOne(new LambdaQueryWrapper<AiModelConfigEntity>()
                .eq(AiModelConfigEntity::getModelName, modelName));
    }

    @Override
    public void add(AiModelConfigDTO dto) {
        AiModelConfigEntity entity = new AiModelConfigEntity();
        BeanUtils.copyProperties(dto, entity);
        aiModelConfigMapper.insert(entity);
    }

    @Override
    public void update(AiModelConfigDTO dto) {
        AiModelConfigEntity entity = new AiModelConfigEntity();
        BeanUtils.copyProperties(dto, entity);
        aiModelConfigMapper.updateById(entity);
    }

    @Override
    public void delete(Long id) {
        aiModelConfigMapper.deleteById(id);
    }

    @Override
    public List<AiModelConfigEntity> listAll() {
        return aiModelConfigMapper.selectList(null);
    }
} 